Skip to content

Node Params Server#438

Open
tvk777 wants to merge 3 commits intomate-academy:masterfrom
tvk777:develop
Open

Node Params Server#438
tvk777 wants to merge 3 commits intomate-academy:masterfrom
tvk777:develop

Conversation

@tvk777
Copy link

@tvk777 tvk777 commented Dec 22, 2025

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This requires a couple of changes before it can be approved. You've done a great job setting up the server structure, but there are two critical issues that break its functionality.

First, the base URL provided to the URL constructor in src/createServer.js is invalid. It uses a backslash (http:\\...) which will cause the server to crash. This should be corrected to use forward slashes: http://${req.headers.host}.

Second, the pathname parsing doesn't correctly handle doubled slashes as required. When a path like //hello is split by /, it produces empty strings. Your current filter logic doesn't remove these, leading to an incorrect parts array. Please adjust your filter to correctly handle these empty strings.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines 9 to 10
.slice(1)
.filter((part) => part !== '/');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic for parsing the pathname doesn't correctly handle doubled slashes. slice(1) only removes the first element, which is not sufficient for paths starting with //. Additionally, the filter condition part !== '/' is incorrect, as split('/') produces empty strings for consecutive slashes, not '/' characters.

const server = http.createServer((req, res) => {
res.setHeader('Content-Type', 'application/json');

const url = new URL(req.url, `http:\\${req.headers.host}`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base URL provided to the URL constructor is not correctly formatted. A backslash (\) is used as a separator, but the standard requires forward slashes (//) after the protocol. The correct format is http://${req.headers.host}.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Excellent work! I am approving this submission. You've successfully addressed all the feedback from the previous review. The base URL for the URL constructor is now correct, and the logic for parsing the pathname properly handles double slashes by filtering out the empty strings. The server now meets all the requirements. Great job!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants